package com.liu.frame.http;

import com.google.gson.Gson;
import com.google.gson.TypeAdapter;

import java.io.IOException;

import okhttp3.ResponseBody;
import retrofit2.Converter;

/**
 * Created by 刘智强 on 2016/10/31.
 */

public class CustomGsonResponseBodyConverter<String> implements Converter<ResponseBody, java.lang.String> {
    private final Gson gson;
    private final TypeAdapter<String> adapter;

    public CustomGsonResponseBodyConverter(Gson gson, TypeAdapter<String> adapter) {
        this.gson = gson;
        this.adapter = adapter;
    }

    @Override
    public java.lang.String convert(ResponseBody value) throws IOException {
        try {
            return value.string();
        } finally {
            value.close();
        }
    }
}
